<script lang="ts" setup>
import printJS from 'print-js';

function printTable() {
  printJS({
    printable: [
      { name: 'soybean', wechat: 'honghuangdc', remark: '欢迎来技术交流' },
      { name: 'soybean', wechat: 'Handsome_mar', remark: '欢迎来技术交流' }
    ],
    properties: ['name', 'wechat', 'remark'],
    type: 'json'
  });
}
function printImage() {
  printJS({
    printable: ['https://www.dotnetshare.com/images/netfenxiang.png'],
    type: 'image',
    header: 'Multiple Images',
    imageStyle: 'width:100%;'
  });
}
</script>

<template>
  <div class="h-full">
    <NCard title="打印" :bordered="false" class="card-wrapper">
      <NButton type="primary" class="mr-10px" @click="printTable">打印表格</NButton>
      <NButton type="primary" @click="printImage">打印图片</NButton>
      <template #footer>
        <GithubLink label="printJS：" link="https://github.com/crabbly/Print.js" class="mt-10px" />
      </template>
    </NCard>
  </div>
</template>

<style scoped></style>
